package vip.meeet.algorithm.arr;



import org.junit.jupiter.api.Test;

import java.util.Arrays;

public class Num27 {

    public static void main(String[] args) {
        int[] a = {3,2,2,3};
        int[] b = {0,1,2,2,3,0,4,2};
        removeElement(a,3);
        System.out.println(Arrays.toString(a));

        removeElement(b,2);
        System.out.println(Arrays.toString(b));

    }
    public static int removeElement(int[] nums,int val) {
        if(nums.length == 0){
            return nums.length;
        }
        int len = 0;
        for(int i=0;i<nums.length;i++){
            while (i<nums.length && nums[i] == val){
                i++;
            }
            if(i == nums.length){
                break;
            }
            if(nums[i] != val){
                nums[len++] = nums[i];
            }
        }
        return len;
    }

    @Test
    public void index(){//28
        String haystack = "aaaaa";
        String needle = "bb";
        System.out.println(haystack.indexOf(needle));
    }
}
